$(document).ready(function() {
        var favs = $("span").get();

        $("span").bind('click',function(){
                var id=$(this).attr('id');
                var class=$(this).attr('class');
                if(class=='myfav')
                {
                    var nclass='nofav'
                    var txt='outmyfav'
                }
                else
                {
                    var nclass='myfav'
                     var txt='inmyfav'
                }
                var data='id='+id+'&do='+nclass
                var toThis=this;
                $.ajax({
                    type:"POST",
                    url:"aj_fav.php",
                    data: data,
                    success: function (html) {
                        $(toThis).removeClass(class);
                        $(toThis).addClass(nclass);
                        $(toThis).text(txt)
                    }
                });
        })
    })
